const {
  unDefined,
  nullValue,
  emailver,
  passwordver,
} = require("@/utils/valiData");
const result = require("@/utils/handle");
// 发起结伴
const InitiatingPartner = (
  description,
  image,
  city,
  full_address,
  companion_time,
  number_of_people
) => {
  unDefined([
    description,
    image,
    city,
    full_address,
    companion_time,
    number_of_people,
  ]);
  nullValue([
    { value: description, tips: "请填写描述" },
    { value: image, tips: "请上传图片" },
    { value: city, tips: "请选择目的地" },
    { value: full_address, tips: "请选择目的地" },
    { value: companion_time, tips: "请选择结伴时间" },
    { value: number_of_people, tips: "请选择希望人数" },
  ]);
  if (!Array.isArray(image)) {
    throw new result("image字段应为数组类型", 422);
  }
  if (image.length === 0) {
    throw new result("请上传图片", 422);
  }
};

// 报名结伴
const SignupPartner = (signup_id, contact_inform, gender, introduce) => {
  unDefined([signup_id, contact_inform, gender, introduce]);
  nullValue([
    { value: signup_id, tips: "缺少_id" },
    { value: contact_inform, tips: "请填写联系方式" },
    { value: gender, tips: "请选择性别" },
    { value: introduce, tips: "请填写自我介绍" },
  ]);
};

// 首页筛选活动
const CompanionQuery = (city, keyword, page) => {
  unDefined([city, keyword, page]);
  nullValue([
    { value: city, tips: "缺少选择城市city查询值" },
    { value: keyword, tips: "缺少选择月份keyword查询值" },
    { value: page, tips: "缺少分页page值" },
  ]);
};

const CompanionDetails = (_id) => {
  unDefined([_id]);
  nullValue([{ value: _id, tips: "请输入_id" }]);
};

const Resreturn = (page) => {
  unDefined([page]);
  nullValue([{ value: page, tips: "请输入页码" }]);
};

const Commentget = (article_id, page) => {
    unDefined([article_id, page])
    nullValue([
        { value: article_id, tips: '缺少_id' },
        { value: page, tips: '缺少分页值' }
    ])
  }

module.exports = {
  InitiatingPartner,
  SignupPartner,
  CompanionQuery,
  CompanionDetails,
  Resreturn,
  Commentget,
};
